// 部分样式来源于其他开源UI库

@import './vars';

@toolBarHeight: 35px;
@toolBarPadding: 4px;

.@{prefix} {
  width: 100%;
  height: 400px;
  position: relative;
  box-sizing: border-box;
  border: 1px solid hsv(0, 0, 90%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: @bkColor;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI',
    system-ui, ui-sans-serif, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji';

  /* 浏览器滚动条 */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-corner,
  ::-webkit-scrollbar-track {
    background-color: #e2e2e2;
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background-color: rgba(0, 0, 0, 0.3);
  }

  ::-webkit-scrollbar-button:vertical {
    display: none;
  }

  ::-webkit-scrollbar-thumb:vertical:hover {
    background-color: rgba(0, 0, 0, 0.35);
  }

  ::-webkit-scrollbar-thumb:vertical:active {
    background-color: rgba(0, 0, 0, 0.38);
  }

  &-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    overflow: hidden;
  }

  &-menu {
    margin: 0;
    padding: 0;
    border-radius: 3px;
    border: 1px solid @borderColor;

    &-item {
      list-style: none;
      font-size: 12px;
      color: @color;
      padding: 4px 10px;
      cursor: pointer;

      &:first-of-type {
        padding-top: 8px;
      }

      &:last-of-type {
        padding-bottom: 8px;
      }

      &:hover {
        background-color: @hover;
      }
    }
  }

  &-table-shape {
    padding: 4px;
    border-radius: 3px;
    border: 1px solid @borderColor;
    display: flex;
    flex-direction: column;

    &-row {
      display: flex;
    }

    &-col {
      padding: 2px;
      cursor: pointer;

      &-default {
        width: 16px;
        height: 16px;
        background-color: #e0e0e0;
        border-radius: 3px;
        transition: all 0.2s;
      }

      &-include {
        background-color: #aaa;
      }
    }
  }

  &-toolbar-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      height: 0 !important;
    }

    .@{prefix}-toolbar {
      min-width: 850px;
      padding: @toolBarPadding;
      height: @toolBarHeight;
      border-bottom: 1px solid hsv(0, 0, 90%);
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-sizing: content-box;

      &-item {
        height: 24px;
        display: inline-block;
        padding: 0 4px;
        transition: all 0.3s;
        border-radius: 0;
        cursor: pointer;
        list-style: none;
        user-select: none;

        &:hover {
          border-radius: 3px;
          background-color: rgb(230, 230, 230);
        }
      }

      &-left,
      &-right {
        padding: 1px 0;
        display: flex;
        align-items: center;
      }
    }
  }

  &-content {
    display: flex;
    height: calc(100% - @toolBarHeight - 2 * @toolBarPadding - 1px);

    .@{prefix}-input-wrapper {
      flex: 1;
      box-sizing: border-box;

      textarea {
        width: 100%;
        height: 100%;
        padding: 10px 20px;
        box-sizing: border-box;
        font-size: 1em;
        font-family: -apple-system, Consolas, BlinkMacSystemFont, 'Segoe UI', Helvetica,
          Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
        resize: none;
        border: none;
        outline: none;
        overflow-y: scroll;
        color: inherit;
        background-color: inherit;
      }

      textarea.textarea-only {
        overflow-y: auto;
      }
    }

    .@{prefix}-preview-wrapper {
      flex: 1;
      box-sizing: border-box;
      overflow: auto;
    }

    .@{prefix}-preview,
    .@{prefix}-html {
      padding: 10px 20px;
      font-size: 16px;
      position: relative;
      word-break: break-all;
    }
  }

  &-form-item {
    margin-bottom: 14px;
    text-align: center;

    &:last-of-type {
      margin-bottom: 0;
    }
  }

  &-lable {
    font-size: 14px;
    color: @color;
    width: 80px;
    text-align: center;
    display: inline-block;
  }

  &-input {
    border-radius: 4px;
    padding: 4px 11px;
    color: @color;
    font-size: 14px;
    line-height: 1.5715;
    background-color: @bkColor;
    background-image: none;
    border: 1px solid @borderColor;
    transition: all 0.2s;

    &:focus {
      border-color: #57a3f3;
      outline: 0;
      box-shadow: 0 0 0 2px rgb(45 140 240 / 20%);
    }
  }

  &-btn {
    font-weight: 400;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    user-select: none;
    height: 32px;
    padding: 0 15px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s linear;
    color: #515a6e;
    background-color: @bkColor;
    border-color: @borderColor;
    margin-left: 10px;

    &:first-of-type {
      margin-left: 0;
    }

    &:hover {
      color: #57a3f3;
      background-color: @bkColor;
      border-color: #57a3f3;
    }

    &-row {
      width: 100%;
    }
  }

  &-katex-block {
    text-align: center;
    margin: 20px;
  }
}

.@{prefix}-previewOnly {
  border: none;
  height: auto;

  .@{prefix}-content {
    height: 100%;
  }

  .@{prefix}-preview {
    padding: 0;
  }
}

.@{prefix}-dark {
  color: @colorDark;
  background-color: @bkColorDark;
  border-color: @borderColorDark;

  // 工具栏
  .@{prefix}-toolbar {
    border-color: @borderColorDark;

    &-item:hover {
      background-color: @hoverdark;
    }
  }

  .@{prefix}-table-shape {
    border-color: @borderColorDark;

    &-col {
      &-default {
        background-color: #222;
      }

      &-include {
        background-color: #555;
      }
    }
  }

  // 弹框组件
  .@{prefix}-modal {
    background-color: @bkColorDark;
    border-color: @borderColorDark;

    &-header {
      border-color: @borderColorDark;
      color: @colorDark;

      .@{prefix}-modal-title {
        color: @colorDark;
      }
    }
  }

  // 下拉组件
  .@{prefix}-dropdown-overlay {
    background-color: @bkColorDark;
  }

  .@{prefix}-menu {
    border-color: @borderColorDark;
  }

  // 内容菜单
  .@{prefix}-menu {
    background-color: inherit;

    &-item {
      color: @colorDark;

      &:hover {
        background-color: @hoverdark;
      }
    }
  }

  .@{prefix}-lable {
    color: @colorDark;
  }

  .@{prefix}-input,
  .@{prefix}-btn {
    color: @colorDark;
    background-color: @bkColorDark;
    border-color: @borderColorDark;
  }

  ::-webkit-scrollbar-corner,
  ::-webkit-scrollbar-track {
    background-color: rgb(15, 15, 15);
  }

  ::-webkit-scrollbar-thumb {
    background-color: @borderColorDark;
  }

  ::-webkit-scrollbar-thumb:vertical:hover {
    background-color: rgb(58, 58, 58);
  }

  ::-webkit-scrollbar-thumb:vertical:active {
    background-color: rgb(58, 58, 58);
  }
}

.@{prefix}-fullscreen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto !important;
  height: auto !important;
  z-index: 10000;
}

.mermaid,
.@{prefix}-katex-inline,
.@{prefix}-katex-block {
  display: none;
}

.mermaid[data-processed],
.@{prefix}-katex-inline[data-processed] {
  display: initial;
}

.@{prefix}-katex-block[data-processed] {
  display: block;
}
